home *** CD-ROM | disk | FTP | other *** search
- /* Checkboxes.c */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <Sound.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include <Appearance.h>
- #include <stdlib.h>
-
- #include "Globals.h"
- #include "ResourceDefs.h"
- #include "DoScrap.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "ControlUtils.h"
- #include "Dispatcher.h"
- #include "DDocData.h"
- #include "EverythingEngine.h"
- #include "EverythingDoc.h"
- #include "Checkboxes.h"
-
-
- static EverythingEngine* GetEngine (Checkboxes* self);
-
- static void DoUndo (Checkboxes* self);
- static void DoCut (Checkboxes* self);
- static void DoCopy (Checkboxes* self);
- static void DoPaste (Checkboxes* self);
- static void DoClear (Checkboxes* self);
- static void DoSelectAll (Checkboxes* self);
- static void DoShowClipboard (Checkboxes* self);
-
-
- //----------
- Checkboxes* NewCheckboxes ()
- {
- Checkboxes* window;
-
- window = (Checkboxes*)malloc (sizeof (Checkboxes));
- Checkboxes_Init (window);
- SetClassID (window, classCheckboxes);
-
- return window;
- }
-
- //----------
- void DeleteCheckboxes (
- Checkboxes* window)
- {
- Checkboxes_Free (window);
- free (window);
- }
-
- //----------
- void Checkboxes_Create (
- AMDoc* inDoc,
- DDocData* inData)
- {
- Checkboxes* winObj = NewCheckboxes ();
-
- if (winObj != nil) {
- Checkboxes_Open (winObj, inDoc, inData);
- }
- }
-
- //----------
- void Checkboxes_Init (
- Checkboxes* self)
- {
- }
-
- //----------
- void Checkboxes_Free (
- Checkboxes* self)
- {
- }
-
- //----------
- EverythingEngine* GetEngine (
- Checkboxes* self)
- {
- return (EverythingEngine*) self->super.mDoc->mEngine;
- }
-
- /*----------*/
- void Checkboxes_Open (
- Checkboxes* self,
- AMDoc* inDoc,
- DDocData* inData)
- {
- WindowPtr window;
- Handle wftb;
-
- self->super.mDoc = inDoc;
- self->mData = inData;
- AddResponder ((AMSignaler*) self->mData, (AMResponder*) self);
-
- window = GetNewCWindow (WIND_Checkboxes, nil, (WindowPtr) -1L);
- if (AMEngine_GetFilename (self->super.mDoc->mEngine) [0] != 0) {
- SetWTitle (window, AMEngine_GetFilename (self->super.mDoc->mEngine));
- }
- self->super.mWindow = window;
- ((EverythingDoc*)self->super.mDoc)->mCheckboxesPtr = window;
-
- SetWindowKind (window, 'AM');
- SetWRefCon (window, (long) self);
- SetPort (window);
- SetInfo (window);
-
- wftb = GetResource ('Wftb', WIND_Checkboxes);
-
- CreateRootControl (window, &self->super.mRootControl);
-
- self->super.vScroll = nil;
- self->super.hScroll = nil;
-
-
- self->mStandard2Handle = GetNewControl (CNTL_Standard2, window);
- SetWindowItemFont (self->mStandard2Handle, wftb, 1);
- SetControlValue (self->mStandard2Handle, GetStandard (self->mData));
-
- self->mXxHandle = GetNewControl (CNTL_Xx, window);
- SetWindowItemFont (self->mXxHandle, wftb, 2);
- SetControlValue (self->mXxHandle, GetXx (self->mData));
-
- self->mCapTriangleLabel = GetNewControl (CNTL_CapTriangle, window);
- SetWindowItemFont (self->mCapTriangleLabel, wftb, 3);
- SetControlFromTEXT (self->mCapTriangleLabel, TEXT_CapTriangle);
-
- self->mGraphic2Handle = GetNewControl (CNTL_Graphic2, window);
- SetWindowItemFont (self->mGraphic2Handle, wftb, 4);
-
- self->mCapcicn2Label = GetNewControl (CNTL_Capcicn2, window);
- EmbedControl (self->mCapcicn2Label, self->mGraphic2Handle);
- SetWindowItemFont (self->mCapcicn2Label, wftb, 5);
- SetControlFromTEXT (self->mCapcicn2Label, TEXT_Capcicn2);
-
- self->mLight2Handle = GetNewControl (CNTL_Light2, window);
- EmbedControl (self->mLight2Handle, self->mGraphic2Handle);
- SetWindowItemFont (self->mLight2Handle, wftb, 6);
- SetControlValue (self->mLight2Handle, GetLight (self->mData));
-
- self->mCapicl10Label = GetNewControl (CNTL_Capicl10, window);
- EmbedControl (self->mCapicl10Label, self->mGraphic2Handle);
- SetWindowItemFont (self->mCapicl10Label, wftb, 7);
- SetControlFromTEXT (self->mCapicl10Label, TEXT_Capicl10);
-
- self->mLight3Handle = GetNewControl (CNTL_Light3, window);
- EmbedControl (self->mLight3Handle, self->mGraphic2Handle);
- SetWindowItemFont (self->mLight3Handle, wftb, 8);
- SetControlValue (self->mLight3Handle, GetLight2 (self->mData));
-
- self->mCapicl11Label = GetNewControl (CNTL_Capicl11, window);
- EmbedControl (self->mCapicl11Label, self->mGraphic2Handle);
- SetWindowItemFont (self->mCapicl11Label, wftb, 9);
- SetControlFromTEXT (self->mCapicl11Label, TEXT_Capicl11);
-
- self->mIcl8NextHandle = GetNewControl (CNTL_Icl8Next, window);
- EmbedControl (self->mIcl8NextHandle, self->mGraphic2Handle);
- SetWindowItemFont (self->mIcl8NextHandle, wftb, 10);
- SetControlValue (self->mIcl8NextHandle, GetIcl8Next (self->mData));
-
- self->mCapICN2Label = GetNewControl (CNTL_CapICN2, window);
- EmbedControl (self->mCapICN2Label, self->mGraphic2Handle);
- SetWindowItemFont (self->mCapICN2Label, wftb, 11);
- SetControlFromTEXT (self->mCapICN2Label, TEXT_CapICN2);
-
- self->mLR3Handle = GetNewControl (CNTL_LR3, window);
- EmbedControl (self->mLR3Handle, self->mGraphic2Handle);
- SetWindowItemFont (self->mLR3Handle, wftb, 12);
- SetControlValue (self->mLR3Handle, GetLR3 (self->mData));
-
- self->mCapPICT2Label = GetNewControl (CNTL_CapPICT2, window);
- EmbedControl (self->mCapPICT2Label, self->mGraphic2Handle);
- SetWindowItemFont (self->mCapPICT2Label, wftb, 13);
- SetControlFromTEXT (self->mCapPICT2Label, TEXT_CapPICT2);
-
- self->mLR4Handle = GetNewControl (CNTL_LR4, window);
- EmbedControl (self->mLR4Handle, self->mGraphic2Handle);
- SetWindowItemFont (self->mLR4Handle, wftb, 14);
- SetControlValue (self->mLR4Handle, GetLR4 (self->mData));
-
- self->mBevel2Handle = GetNewControl (CNTL_Bevel2, window);
- SetWindowItemFont (self->mBevel2Handle, wftb, 15);
-
- self->mNextAloneHandle = GetNewControl (CNTL_NextAlone, window);
- EmbedControl (self->mNextAloneHandle, self->mBevel2Handle);
- SetWindowItemFont (self->mNextAloneHandle, wftb, 16);
- SetControlValue (self->mNextAloneHandle, GetNextAlone (self->mData));
- SetBevelButtonGraphicAlignment (self->mNextAloneHandle, kControlBevelButtonAlignCenter, 0, 0);
-
- self->mNext3Handle = GetNewControl (CNTL_Next3, window);
- EmbedControl (self->mNext3Handle, self->mBevel2Handle);
- SetWindowItemFont (self->mNext3Handle, wftb, 17);
- SetControlValue (self->mNext3Handle, GetNext (self->mData));
- SetBevelButtonTextPlacement (self->mNext3Handle, kControlBevelButtonPlaceToRightOfGraphic);
- SetBevelButtonTextAlignment (self->mNext3Handle, kControlBevelButtonAlignTextFlushLeft, 0);
- SetBevelButtonGraphicAlignment (self->mNext3Handle, kControlBevelButtonAlignLeft, 0, 0);
-
- self->mNext4Handle = GetNewControl (CNTL_Next4, window);
- EmbedControl (self->mNext4Handle, self->mBevel2Handle);
- SetWindowItemFont (self->mNext4Handle, wftb, 18);
- SetControlValue (self->mNext4Handle, GetNext2 (self->mData));
- SetBevelButtonTextPlacement (self->mNext4Handle, kControlBevelButtonPlaceBelowGraphic);
- SetBevelButtonTextAlignment (self->mNext4Handle, kControlBevelButtonAlignTextCenter, 0);
- SetBevelButtonGraphicAlignment (self->mNext4Handle, kControlBevelButtonAlignTop, 0, 0);
-
- AdvanceKeyboardFocus (window);
-
- ShowWindow (window);
- }
-
- /*----------*/
- void Checkboxes_Close (
- Checkboxes* self)
- {
- RemoveResponder ((AMSignaler*) self->mData, (AMResponder*) self);
-
- ((EverythingDoc*)self->super.mDoc)->mCheckboxesPtr = nil;
- SetInfo (nil);
- HideWindow (self->super.mWindow);
- DisposeWindow (self->super.mWindow);
-
- DeleteCheckboxes (self);
- }
-
- /*----------*/
- void Checkboxes_Track (
- Checkboxes* self,
- ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
- short newValue;
-
- if (whichControl == self->mStandard2Handle) {
- if (TrackCheckbox (self->mStandard2Handle, where)) {
- SetStandard (self->mData, GetControlValue (self->mStandard2Handle) != 0);
- }
- }
- if (whichControl == self->mXxHandle) {
- if (TrackCheckbox (self->mXxHandle, where)) {
- SetXx (self->mData, GetControlValue (self->mXxHandle) != 0);
- }
- }
- if (whichControl == self->mLight2Handle) {
- if (TrackCheckbox (self->mLight2Handle, where)) {
- SetLight (self->mData, GetControlValue (self->mLight2Handle) != 0);
- }
- }
- if (whichControl == self->mLight3Handle) {
- if (TrackCheckbox (self->mLight3Handle, where)) {
- SetLight2 (self->mData, GetControlValue (self->mLight3Handle) != 0);
- }
- }
- if (whichControl == self->mIcl8NextHandle) {
- if (TrackCheckbox (self->mIcl8NextHandle, where)) {
- SetIcl8Next (self->mData, GetControlValue (self->mIcl8NextHandle) != 0);
- }
- }
- if (whichControl == self->mLR3Handle) {
- if (TrackCheckbox (self->mLR3Handle, where)) {
- SetLR3 (self->mData, GetControlValue (self->mLR3Handle) != 0);
- }
- }
- if (whichControl == self->mLR4Handle) {
- if (TrackCheckbox (self->mLR4Handle, where)) {
- SetLR4 (self->mData, GetControlValue (self->mLR4Handle) != 0);
- }
- }
- if (whichControl == self->mNextAloneHandle) {
- if (TrackClick (self->mNextAloneHandle, where)) {
- SetNextAlone (self->mData, GetControlValue (self->mNextAloneHandle) != 0);
- }
- }
- if (whichControl == self->mNext3Handle) {
- if (TrackClick (self->mNext3Handle, where)) {
- SetNext (self->mData, GetControlValue (self->mNext3Handle) != 0);
- }
- }
- if (whichControl == self->mNext4Handle) {
- if (TrackClick (self->mNext4Handle, where)) {
- SetNext2 (self->mData, GetControlValue (self->mNext4Handle) != 0);
- }
- }
- }
-
- //----------
- void Checkboxes_DataChanged (
- Checkboxes* self,
- long inDataID)
- {
- if (inDataID == idStandard) {
- SetControlValue (self->mStandard2Handle, GetStandard (self->mData));
- }
- if (inDataID == idXx) {
- SetControlValue (self->mXxHandle, GetXx (self->mData));
- }
- if (inDataID == idLight) {
- SetControlValue (self->mLight2Handle, GetLight (self->mData));
- }
- if (inDataID == idLight2) {
- SetControlValue (self->mLight3Handle, GetLight2 (self->mData));
- }
- if (inDataID == idIcl8Next) {
- SetControlValue (self->mIcl8NextHandle, GetIcl8Next (self->mData));
- }
- if (inDataID == idLR3) {
- SetControlValue (self->mLR3Handle, GetLR3 (self->mData));
- }
- if (inDataID == idLR4) {
- SetControlValue (self->mLR4Handle, GetLR4 (self->mData));
- }
- if (inDataID == idNextAlone) {
- SetControlValue (self->mNextAloneHandle, GetNextAlone (self->mData));
- }
- if (inDataID == idNext) {
- SetControlValue (self->mNext3Handle, GetNext (self->mData));
- }
- if (inDataID == idNext2) {
- SetControlValue (self->mNext4Handle, GetNext2 (self->mData));
- }
- }
-
- /*----------*/
- void Checkboxes_MouseIn (
- Checkboxes* self,
- Point where,
- short modifiers)
- {
- Rect bounds;
-
- }
-
- //----------
- void Checkboxes_ExitCurField (
- Checkboxes* self)
- {
- ControlHandle focus;
-
- GetKeyboardFocus (self->super.mWindow, &focus);
-
- if (focus == nil) {
- // nothing to exit
-
- }
- }
-
- /*----------*/
- void Checkboxes_TypeIn (
- Checkboxes* self,
- char ch)
- {
- ControlHandle focus;
- short keyCode;
-
- GetKeyboardFocus (self->super.mWindow, &focus);
-
- if ((ch == charEnter)
- || (ch == charReturn)) {
- Checkboxes_ExitCurField (self); // Dispatch
- } else if (ch == charEsc) {
- } else if (ch == charTab) {
- AMWindow_DoTab ((AMWindow*) self, (curEvent.modifiers & optionKey) != 0);
- } else if (focus != nil) {
- keyCode = curEvent.message & keyCodeMask;
- HandleControlKey (focus, keyCode, ch, curEvent.modifiers);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- } else {
- SysBeep (1);
- }
- }
-
- /*----------*/
- void Checkboxes_Resize (
- Checkboxes* self)
- {
- /* application-specific code to resize items in window */
- }
-
- /*----------*/
- void Checkboxes_Scroll (
- Checkboxes* self,
- short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- if (gWhichScroll == self->super.vScroll) {
- } else { // horizontal
- }
- }
-
- //----------
- void DoUndo (
- Checkboxes* self)
- {
- } // DoUndo
-
- //----------
- void DoCut (
- Checkboxes* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TECut (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- scrapDirty = true;
- }
- } // DoCut
-
- //----------
- void DoCopy (
- Checkboxes* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TECopy (curTE);
- scrapDirty = true;
- }
- } // DoCopy
-
- //----------
- void DoPaste (
- Checkboxes* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TEPaste (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- }
- } // DoPaste
-
- //----------
- void DoClear (
- Checkboxes* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TEDelete (curTE);
- AMEngine_SetDirty (self->super.mDoc->mEngine);
- }
- } // DoClear
-
- //----------
- void DoSelectAll (
- Checkboxes* self)
- {
- TEHandle curTE = AMWindow_GetCurTE ((AMWindow*) self);
-
- if (curTE != nil) {
- TESetSelect (0, 32767, curTE);
- }
- } // DoSelectAll
-
- //----------
- void DoShowClipboard (
- Checkboxes* self)
- {
- } // DoShowClipboard
-
- //----------
- Boolean Checkboxes_DoCommand (
- Checkboxes* self,
- long inCommand)
- {
- Boolean result = true;
-
- switch (inCommand) {
- case cmdUndo:
- DoUndo (self);
- break;
- case cmdCut:
- DoCut (self);
- break;
- case cmdCopy:
- DoCopy (self);
- break;
- case cmdPaste:
- DoPaste (self);
- break;
- case cmdClear:
- DoClear (self);
- break;
- case cmdSelectAll:
- DoSelectAll (self);
- break;
- case cmdShowClipboard:
- DoShowClipboard (self);
- break;
-
- default:
- result = false;
- } // switch
-
- return result;
- }
-